Reorganize code a little
authorjustbur <justin@burkett.cc>
Sat, 4 Jul 2015 15:10:20 +0000 (11:10 -0400)
committerjustbur <justin@burkett.cc>
Sat, 4 Jul 2015 15:10:20 +0000 (11:10 -0400)
which-key.el

index ec20b6ca49d749d6abec9f4dc417997f78912a21..898c12e52d0549e15305b1770715a4449ea73c9c 100644 (file)
@@ -93,6 +93,8 @@ currently disabled.")
     (setq-local cursor-in-non-selected-windows nil))
   (setq which-key--setup-p t))
 
+;; Helper functions
+
 (defsubst which-key/truncate-description (desc)
   "Truncate DESC description to `which-key-max-description-length'."
   (if (> (length desc) which-key-max-description-length)
@@ -159,6 +161,8 @@ longest key and description in the buffer, respectively."
                padded-key padded-desc)))
    unformatted))
 
+;; "Core" functions
+
 (defun which-key/get-formatted-key-bindings (buffer key)
   (let ((max-len-key 0) (max-len-desc 0)
         (key-str-qt (regexp-quote (key-description key)))
@@ -234,6 +238,18 @@ Finally, show the buffer."
       ;; command finished maybe close the window
       (which-key/hide-buffer))))
 
+;; Timers
+
+(defun which-key/start-open-timer ()
+  "Activate idle timer."
+  (when which-key--open-timer (cancel-timer which-key--open-timer)); start over
+  (setq which-key--open-timer
+        (run-with-idle-timer which-key-idle-delay t 'which-key/update)))
+
+(defun which-key/stop-open-timer ()
+  "Deactivate idle timer."
+  (cancel-timer which-key--open-timer))
+
 ;; Display functions
 
 (defun which-key/show-buffer-display-buffer (height width)
@@ -271,16 +287,6 @@ Finally, show the buffer."
            (intern (concat "which-key/hide-buffer-" (symbol-name method)))))
         (t (error "error: Invalid choice for which-key-display-method"))))
 
-(defun which-key/start-open-timer ()
-  "Activate idle timer."
-  (when which-key--open-timer (cancel-timer which-key--open-timer)); start over
-  (setq which-key--open-timer
-        (run-with-idle-timer which-key-idle-delay t 'which-key/update)))
-
-(defun which-key/stop-open-timer ()
-  "Deactivate idle timer."
-  (cancel-timer which-key--open-timer))
-
 (provide 'which-key)
 
 ;;; which-key.el ends here